﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Interfaces;
using civilisationLib.GeneratedCode.Implementation;
using System.IO;
using Implementation;

namespace CivilisationWPF
{
    /// <summary>
    /// Logique d'interaction pour SavePartie.xaml
    /// </summary>
    public partial class SavePartie : Window
    {
        private MonteurPartie mont;

        public SavePartie(MonteurPartie monteur)
        {
            mont = monteur;
            InitializeComponent();
        }

        public void sauverJeu(object sender, RoutedEventArgs e)
        {
            SaveLoadPartie saver = new SaveLoadPartie();
            if (nomFichierSave.Text.CompareTo("") == 0)
            {
                int i = 0;
                while (File.Exists("sauvegarde\\save" + i))
                {
                    i++;
                }
                saver.SerializeObject("sauvegarde\\save" + i, mont as MonteurPartieImpl);
            }
            else
            {
                saver.SerializeObject("sauvegarde\\"+nomFichierSave.Text, mont as MonteurPartieImpl);
            }

            this.Close();
        }
    }
}
